<?php

$__FILEPATH__ = dirname(__FILE__)."/";

require_once($__FILEPATH__."../func_common.php");
require_once($__FILEPATH__."../class_def.php");
require_once($__FILEPATH__."../conf/info.php");
CheckAdminAndInitHeader();

$PageArray = array();
$mysqli = GetMysqliInstance();

if (isset($_GET["delete"]) && isset($_GET["id"]))
{
	$id = intval($_GET["id"]);
    $mysqli->query("delete from newslist where id='$id'");
}


$result = $mysqli->query("select id,title,user,ip,time from newslist");
$PageArray["newslist"] = array();
if ($result)
{
	while($row = $result->fetch_array(MYSQLI_ASSOC))
	{
		$NewsItem = new NewsListItem();
		$NewsItem->id = $row["id"];
		$NewsItem->title = $row["title"];
		$NewsItem->user = $row["user"];
		$NewsItem->ip = $row["ip"];
		$NewsItem->time = $row["time"];

		$PageArray["newslist"][] = $NewsItem;
	}

	$result->close();
}

$mysqli->close();

?>